package com.tianpengtech.front.mobile.message;

import com.tianpengtech.common.model.user.User;
import com.tianpengtech.front.mobile.common.util.R;
import com.tianpengtech.front.mobile.common.util.U;
import com.tianpengtech.front.mobile.common.util.UserUtil;
import com.tianpengtech.front.web.common.controller.BaseController;

/**
 * Created by ggd on 2017/7/23 0023.
 */
public class MobileMessageController extends BaseController {

    private static MobileMessageService messageService = new MobileMessageService();
    /**
     * 获取消息列表
     */
    public void index(){
        int pageNum = getParaToInt("pageNum",1);
        int pageSize = getParaToInt("pageSize",5);
//        User user=UserUtil.getCurrentUser(getPara("token"),getHeader("source"));
        R r=messageService.messageList(pageNum,pageSize,46);
        renderJson(r);
    }

    /**
     * 获取消息详情
     */
    public void getMessage(){
        String id=getPara("id");
        if (!U.isInteger(id)){
            renderJson(R.fail("数据格式不正确"));
            return;
        }
//        User user=UserUtil.getCurrentUser(getPara("token"),getHeader("source"));
        R r=messageService.getMessage(id,46);
        renderJson(r);
    }

    /**
     * 获取用户是否有未读消息
     */
    public void unRead(){
//        User user=UserUtil.getCurrentUser(getPara("token"),getHeader("source"));
        R r=messageService.isUnreadMsg(46);
        renderJson(r);
    }


}
